/**
 * @file BaseMsgHandler.h
 * @author huangxiaozhu (xiaozhuhuang2014@163.com)
 * @brief  通讯消息基类，子类实现具体的消息处理
 * @version 1.0.0
 * @date 2024-02-26
 * 
 * @copyright Copyright (c) 2024
 * 
 */

#pragma once

#include <string>
#include <memory>


class BaseMsgHandler;
using BaseMsgHandlerPtr = std::shared_ptr<BaseMsgHandler>;

class BaseMsgHandler
{
public:
    BaseMsgHandler() = default;
    virtual ~BaseMsgHandler() = default;

    virtual bool Init(){return true;}
    void SetMsgInfo(const std::string& msgHead, int msgLength);

    std::string GetMsgType();
    int GetMsgLength();

    virtual bool HandleMsg(const std::string& msg);               // 消息处理的公共入口
protected:
    virtual bool HandleMsgSub(const std::string& msg) = 0;        // 子类处理具体消息流程

protected:
    std::string m_msgType;           // msg type
    int m_msgLength;                 // msg length
};